//
//  LTChannelLabel.m
//  wangyiNews08
//
//  Created by 123 on 16/3/12.
//  Copyright © 2016年 Tsr. All rights reserved.
//

#import "LTChannelLabel.h"

// 选中的大字体
#define LTBigFont 18
// 默认字体
#define LTSmallFont 14

@implementation LTChannelLabel

+ (instancetype)labelWithTitle:(NSString *)title {
    // 创建标签
    LTChannelLabel *label = [[LTChannelLabel alloc] init];
    
    label.text = title;
    
    label.font = [UIFont systemFontOfSize:LTBigFont];
    
    [label sizeToFit];
    
    label.font = [UIFont systemFontOfSize:LTSmallFont];
    
    // 设置label可交互
    label.userInteractionEnabled = YES;
    
    return label;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    if (self.labelSelectedBolck) {
        self.labelSelectedBolck();
    }
}

- (void)setScale:(CGFloat)scale {
    _scale = scale;
    
    // label文字中变化的百分比
    CGFloat percent = (LTBigFont - LTSmallFont) / (CGFloat)LTSmallFont;
    
    // 计算真实的百分比
    percent = percent * scale + 1;
    
    self.transform = CGAffineTransformMakeScale(percent, percent);
    
    // 要显示的label颜色(0:黑 - 1:红)
    self.textColor = [UIColor colorWithRed:scale green:0 blue:0 alpha:1];
}


@end
